package com.tusuo.stds.ui.scenesetting;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;

import com.flyco.tablayout.CommonTabLayout;
import com.flyco.tablayout.listener.CustomTabEntity;
import com.tusuo.stds.R;
import com.tusuo.stds.rest.SceneList;
import com.tusuo.stds.ui.BaseToolbarActivity;
import com.tusuo.stds.ui.ToolbarOwner;
import com.tusuo.stds.ui.main.TabEntity;
import com.tusuo.stds.ui.scenesearch.SceneSearchActivity_;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;

import java.util.ArrayList;
import java.util.List;

import cn.lemon.view.adapter.MultiTypeAdapter;
import rx.functions.Action0;

/**
 * Created by developer on 17-8-28.
 */

@EActivity(R.layout.activity_scene_setting)
public class SceneSettingActivity extends BaseToolbarActivity<SceneSettingView,SceneSettingPresenter> implements SceneSettingView{

    @ViewById(R.id.scene_setting_tab)
    CommonTabLayout mTabLayout;

    private String[] mTitles = {"已开通", "未开通"};
    private ArrayList<CustomTabEntity> mTabEntities = new ArrayList<>();
    private ArrayList<Fragment> mFragmentList = new ArrayList<>();

    @NonNull
    @Override
    public SceneSettingPresenter createPresenter() {
        return new SceneSettingPresenter(this);
    }

    @AfterViews
    void initData() {
        setupUI(this);
        List<ToolbarOwner.MenuAction> menuActionList = new ArrayList<>();
        ToolbarOwner.MenuAction menuAction = new ToolbarOwner.MenuAction("", new Action0() {
            @Override
            public void call() {
                Intent intent = new Intent();
                intent.setClass(SceneSettingActivity.this, SceneSearchActivity_.class);
                startActivity(intent);
            }
        }, R.drawable.st_confirm_btn_search);

        menuActionList.add(menuAction);

        ToolbarOwner.Config config = new ToolbarOwner.Config("场景设置", true, menuActionList);
        mToolbarOwner.setConfig(config);

        mFragmentList.add(UnLockFragment_.builder().build());
        mFragmentList.add(LockFragment_.builder().build());

        for (int i = 0; i < mTitles.length; i++) {
            mTabEntities.add(new TabEntity(mTitles[i], 0, 0));
        }

        mTabLayout.setTabData(mTabEntities, this, R.id.scene_setting_content, mFragmentList);

    }
}
